package gobase

import (
	"gitee.com/ymofen/factory"
)

var (
	RegisterFactoryCreateFunc = func(id string, fn func(...any) (any, error)) error {
		return factory.DefaultCreator.RegisterCreator(id, fn)
	}

	UnregisterFactoryCreateFunc = func(id string) {
		factory.DefaultCreator.UnregisterCreator(id)
	}

	CreateFactoryInstance = func(id string, args ...any) (any, error) {
		return factory.DefaultCreator.Create(id, args...)
	}

	RegisterFactoryVar = func(id string, val any) error {
		return factory.DefaultVarStorer.RegisterVar(id, val)
	}

	GetFactoryVar = func(id string) any {
		return factory.DefaultVarStorer.GetVar(id)
	}

	// 	RemoveVar(id string)
	//	RangeVarList(cb func(val any) bool)
	//	RangeVarKVList(cb func(key string, val any) bool)
	RemoveFactoryVar = func(id string) {
		factory.DefaultVarStorer.RemoveVar(id)
	}

	RangeFactoryVarList = func(cb func(val any) bool) {
		factory.DefaultVarStorer.RangeVarList(cb)
	}

	RangeFactoryVarListEx = func(cb func(key string, val any) bool) {
		factory.DefaultVarStorer.RangeVarKVList(cb)
	}
)
